package com.deke.home.controller;

import com.deke.entity.TbBottomArticle;
import com.deke.home.dao.TbBottomArticleDao;
import com.deke.home.service.TbBottomArticleService;
import com.deke.home.vo.TbBottomArticleVo;
import com.deke.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author ：ludi（206913808@qq.com）
 * @date ：Created in 2022/12/9 16:00
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/home/bottomarticle")
@Api(tags = "底部文章")
public class TbBottomArticleController {

    @Autowired
    private TbBottomArticleService tbBottomArticleService;

    @Autowired
    private TbBottomArticleDao tbBottomArticleDao;


    @ApiOperation(value = "分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "current", value = "当前页码"),
            @ApiImplicitParam(name = "pageSize", value = "每页显示的条数")
    })
    @PostMapping("getAllBottomArticle/{current}/{pageSize}")
    public Result getAllBottomArticle(@PathVariable(required = true,value = "current") Integer current, @PathVariable(required = true) Integer pageSize, @RequestBody TbBottomArticleVo tbBottomArticleVo){
        Result result = tbBottomArticleService.queryByConditionPage(current, pageSize, tbBottomArticleVo);
        return new Result(2000, "查询成功", result);
    }


    @ApiOperation(value = "删除操作")
    @PostMapping("deleteBottomArticle")
    public Result deleteBottomArticle(@RequestBody Map map){
        return tbBottomArticleService.deleteBottomArticle(map);
    }


    @ApiOperation(value = "添加操作")
    @PostMapping("addBottomArticle")
    public Result addBottomArticle(@RequestBody TbBottomArticle tbBottomArticle){
        return tbBottomArticleService.addBottomArticle(tbBottomArticle);
    }


    @ApiOperation(value = "修改状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id"),
            @ApiImplicitParam(name = "是否禁用", value = "isDisable")
    })
    @PostMapping("changeStatus/{id}/{isDisable}")
    public Result changeStatus(@PathVariable String id,@PathVariable Integer isDisable){
        return tbBottomArticleService.changeStatus(id, isDisable);
    }



    @ApiOperation(value = "编辑")
    @PostMapping("editBottomArticle")
    public Result editBottomArticle(@RequestBody TbBottomArticle tbBottomArticle){
        return tbBottomArticleService.editBottomArticle(tbBottomArticle);
    }
}